package cn.usian;

import java.util.Scanner;

public class demo10 {
    public static void main(String[] args) {
        demo01();
        demo02();
    }

    public static void demo01(){
        //定义一个数组
        int[] x={2,4,1,7,6};
        for (int i = 0; i < x.length; i++) {
           if (i==x.length-1){
               System.out.println(x[i]);
           }else {
               System.out.print(x[i]+",");
           }
        }
    }

    public static void demo02(){
        //2.编写一段java代码实现字符串反转
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入一个字符串：");
        String s = scanner.nextLine();
        StringBuilder stringBuilder = new StringBuilder(s);
        StringBuilder reverse = stringBuilder.reverse();
        System.out.println("反转后的字符串为："+reverse);
    }


}
